<template>
    <div>

    </div>
</template>

<script>
    import {
        getLift,
        getGreenBuilding,
        getCameraImage,
        getTrafficSpeed,
        getBridge,
        getCampus,
        getFlood,
    } from '@/api/data';
    import {
        SetCameraInfo,
        AddCustom_POI,
        AddPOI
    } from '@/util/poi'
    import { delay } from '@/util/date'
    export default {
        name: 'BRIDGE',
        props: [''],
        data() {
            return {
                bridgeList: []
            };
        },

        components: {},

        computed: {},

        beforeMount() {},

        async mounted() {
            this.bridgeList = await getBridge();
            this.setCameraInfo()
            this.addPoi()
        },

        methods: {
            // //设置当前镜头视界和绕中心点转动
            async setCameraInfo() {
                let jsondata = SetCameraInfo("103.628922,1.353528")
                window.cloudRender.SuperAPI("SetCameraInfo", jsondata)
                await delay(1200)
                // 绕中心点转动
                window.cloudRender.SuperAPI("SetCameraRotate", {
                    "time": 300,
                    "direction": "clockwise" //"anticlockwise"
                })
            },
            //增加poi点
            async addPoi() {
                let removeJsondata = {
                    "covering_type": "poi" //覆盖物类型, 详见下表
                }
                window.cloudRender.SuperAPI("RemoveAllCovering", removeJsondata);
                // 循环打点
                if (Array.isArray(this.bridgeList.Bridge) && this.bridgeList.Bridge.length > 1) {
                    for (let i = 0; i < this.bridgeList.Bridge.length; i++) {
                        let html = location.origin + '/html/bridge.html?content=' + JSON.stringify(this.bridgeList.Bridge[i])
                        let {
                            guid,
                            lon,
                            lat,
                            imageurl
                        } = this.bridgeList.Bridge[i];
                        let jsondata = AddCustom_POI(guid, lon + ',' + lat, html);
                        window.cloudRender.SuperAPI("AddCustomPOI", jsondata, (status, progress) => {
                            console.log(status, progress, '加入poi点第', i);
                        })
                    }
                    // // 聚焦所有POI
                    // setTimeout(() => {
                    //   window.cloudRender.SuperAPI('FocusAllPOI')
                    // }, 500)
                }
            }
        },

        watch: {}

    }
</script>
<style lang='' scoped>

</style>